<?php
class widget_menu_category extends CWidget {
  public function run() {
    $categories   = Category::model()->getCategories();
    $catID        = '';
    if (Yii::app()->controller->id == 'product' && Yii::app()->controller->action->id == 'index' && !empty($_GET['catID'])) {
      $catID = $_GET['catID'];
    }
    if (Yii::app()->controller->id == 'product' && Yii::app()->controller->action->id == 'detail' && !empty($_GET['id'])) {
      Yii::import('application.controllers.ProductController');
      $controller_product = new ProductController("Product");
      $product            = $controller_product->loadModel($_GET['id']);
      $catID              = md5($product->categoryID);
    }
    
    $this->render('widget_menu_category', array(
      'categories' => $categories, 
      'categoryID' => $catID
    ));
  }
}
?>